package com.javaee.ejb.entity;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Date;


/**
 * The persistent class for the message database table.
 * 
 */
@Entity
@Table(name="message")
@NamedQueries(
{
    @NamedQuery(name = "GetMessagesByConversation", query = "SELECT OBJECT (msg) FROM Message msg WHERE msg.conversation_idconversation = :p_conv ORDER BY msg.idmessage ASC"),
})
public class Message implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int idmessage;

	private String content;

	private int idconv;

    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="send_time")
	private Date sendTime;

	//bi-directional many-to-one association to Employee
    int id_author;

	private int conversation_idconversation;

    public Message() {
    }

	public int getIdmessage() {
		return this.idmessage;
	}

	public void setIdmessage(int idmessage) {
		this.idmessage = idmessage;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getIdconv() {
		return this.idconv;
	}

	public void setIdconv(int idconv) {
		this.idconv = idconv;
	}

	public Date getSendTime() {
		return this.sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public int getAuthorId() {
		return this.id_author;
	}

	public void setAuthor(int authorid) {
		this.id_author = authorid;
	}
	
	public int getConversationId() {
		return this.conversation_idconversation;
	}

	public void setConversation(Conversation conversation) {
		this.conversation_idconversation = conversation.getIdconversation();
	}
	
}